<template>
  <div class="info-panel">
    <div class="info-content">
      <div class="info-item">
        <span class="info-label">新闻事件：</span>
        <span class="info-value">{{ info.title || '暂无' }}</span>
      </div>
      <div class="info-item">
        <span class="info-label">媒体级别：</span>
        <span class="info-value">{{ info.mediaLevel || '暂无' }}</span>
      </div>
      <div class="info-item">
        <span class="info-label">报道时间：</span>
        <span class="info-value">{{ formatReportTime(info.reportTime) || '暂无' }}</span>
      </div>
      <div class="info-item">
        <span class="info-label">媒体名称：</span>
        <span class="info-value">{{ info.mediaName || '暂无' }}</span>
      </div>
      <div class="info-item">
        <span class="info-label">成果归属：</span>
        <span class="info-value">{{ info.remarks || '暂无' }}</span>
      </div>
    </div>
  </div>
</template>

<script setup>
const props = defineProps({
  info: {
    type: Object,
    default: () => ({})
  }
})

// 格式化报道时间
const formatReportTime = (time) => {
  if (!time) return null

  try {
    // 处理时间戳或日期字符串
    const date = typeof time === 'number' || (typeof time === 'string' && /^\d+$/.test(time))
        ? new Date(Number(time))
        : new Date(time)

    // 检查是否为有效日期
    if (isNaN(date.getTime())) return null

    // 格式化为YYYY年MM月DD日
    const year = date.getFullYear()
    const month = String(date.getMonth() + 1).padStart(2, '0')
    const day = String(date.getDate()).padStart(2, '0')
    const hours = String(date.getHours()).padStart(2, '0')
    const minutes = String(date.getMinutes()).padStart(2, '0')

    return `${year}年${month}月${day}日 ${hours}:${minutes}`
  } catch (e) {
    console.error('时间格式化错误:', e)
    return null
  }
}
</script>

<style scoped>
.info-panel {
  height: 100%;
}

.info-content {
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
}

.info-item {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 12px;
  color: #9aa0a6;
  font-weight: 500;
}

.info-value {
  font-size: 13px;
  color: #e8eaed;
  word-break: break-all;
  line-height: 1.4;
}

/* 滚动条样式优化 */
.info-content::-webkit-scrollbar {
  width: 8px;
}

.info-content::-webkit-scrollbar-track {
  background: #323639;
}

.info-content::-webkit-scrollbar-thumb {
  background: #5f6368;
  border-radius: 4px;
}

.info-content::-webkit-scrollbar-thumb:hover {
  background: #80868b;
}
</style>
